package com.threeti.mecool.core.domain.model.plan.pojo;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;

public class UserTask {
	private Long id;
	private Integer version;
	private Task task;
	private transient Long taskId;
	private String taskData;
	private UserStep userStep;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@JsonIgnore
	public Task getTask() {
		if (task == null && taskId != null) {
			task = userStep.getStep().getTask();
		}
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	public String getTaskData() {
		return taskData;
	}

	public void setTaskData(String taskData) {
		this.taskData = taskData;
	}

	@JsonBackReference
	public UserStep getUserStep() {
		return userStep;
	}

	public void setUserStep(UserStep userStep) {
		this.userStep = userStep;
	}
	
	public Long getTaskId() {
		if (taskId == null && task != null) {
			taskId = task.getId();
		}
		return taskId;
	}
	
	public void setTaskId(Long taskId) {
		this.taskId = taskId;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
